<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Logagent: plugins/logagent-plugin-api.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Logagent
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_38c8d24aef3972a7f87b834274e76e31.html">plugins</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">logagent-plugin-api.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="logagent-plugin-list_8h_source.html">logagent-plugin-list.h</a>&quot;</code><br />
</div>
<p><a href="logagent-plugin-api_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlog__t.html">log_t</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ab6bc945ce840e4f0a16ec0fb12acc1a0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#ab6bc945ce840e4f0a16ec0fb12acc1a0">MAX_LOG_SIZE</a>&#160;&#160;&#160;1024</td></tr>
<tr class="separator:ab6bc945ce840e4f0a16ec0fb12acc1a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aa8dbecc44cb99a92ba93141441d0a033"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#aa8dbecc44cb99a92ba93141441d0a033">logagent_log_add</a> (struct <a class="el" href="structlist__head.html">list_head</a> *log_list, const char *log)</td></tr>
<tr class="separator:aa8dbecc44cb99a92ba93141441d0a033"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad92bf07e1fcc20b58296e564da85da37"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#ad92bf07e1fcc20b58296e564da85da37">logagent_log_remove</a> (struct <a class="el" href="structlist__head.html">list_head</a> *pos)</td></tr>
<tr class="separator:ad92bf07e1fcc20b58296e564da85da37"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9f828a69257b510a17907c1a3ffc29d1"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#a9f828a69257b510a17907c1a3ffc29d1">logagent_plugin_env_init</a> (void **context)</td></tr>
<tr class="separator:a9f828a69257b510a17907c1a3ffc29d1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a993c424dc9f4fd7e198666a94fa06c63"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#a993c424dc9f4fd7e198666a94fa06c63">logagent_plugin_env_destroy</a> (void **context)</td></tr>
<tr class="separator:a993c424dc9f4fd7e198666a94fa06c63"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad169bca8e73b3ae8c0374e3971f43039"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#ad169bca8e73b3ae8c0374e3971f43039">logagent_plugin_work</a> (void *gconfig, void *pconfig, struct <a class="el" href="structlist__head.html">list_head</a> *log_list)</td></tr>
<tr class="separator:ad169bca8e73b3ae8c0374e3971f43039"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae01dcc8ad838b79d7441a7b804f9f6c7"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#ae01dcc8ad838b79d7441a7b804f9f6c7">logagent_plugin_init</a> (void *gconfig, void **context)</td></tr>
<tr class="separator:ae01dcc8ad838b79d7441a7b804f9f6c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a95dd35e4770fc0510fcc668e78aabd36"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="logagent-plugin-api_8h.html#a95dd35e4770fc0510fcc668e78aabd36">logagent_plugin_exit</a> (void *gconfig, void **context)</td></tr>
<tr class="separator:a95dd35e4770fc0510fcc668e78aabd36"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ab6bc945ce840e4f0a16ec0fb12acc1a0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab6bc945ce840e4f0a16ec0fb12acc1a0">&#9670;&nbsp;</a></span>MAX_LOG_SIZE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MAX_LOG_SIZE&#160;&#160;&#160;1024</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>each log line max string length </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="aa8dbecc44cb99a92ba93141441d0a033"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa8dbecc44cb99a92ba93141441d0a033">&#9670;&nbsp;</a></span>logagent_log_add()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void logagent_log_add </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structlist__head.html">list_head</a> *&#160;</td>
          <td class="paramname"><em>log_list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>log</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>add a log into log list </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">log_list</td><td>the log list shared with plugins </td></tr>
    <tr><td class="paramname">log</td><td>one line log </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ad92bf07e1fcc20b58296e564da85da37"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad92bf07e1fcc20b58296e564da85da37">&#9670;&nbsp;</a></span>logagent_log_remove()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void logagent_log_remove </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structlist__head.html">list_head</a> *&#160;</td>
          <td class="paramname"><em>pos</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>remove log from log list </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pos</td><td>the position of the log to be removed </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a993c424dc9f4fd7e198666a94fa06c63"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a993c424dc9f4fd7e198666a94fa06c63">&#9670;&nbsp;</a></span>logagent_plugin_env_destroy()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int logagent_plugin_env_destroy </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>context</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>plugin global environment destroy </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">context</td><td>take global environment config in </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success</dd></dl>
<p>when logagent exit, it will call all destroy function for all plugins in the plugin list. </p>

</div>
</div>
<a id="a9f828a69257b510a17907c1a3ffc29d1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9f828a69257b510a17907c1a3ffc29d1">&#9670;&nbsp;</a></span>logagent_plugin_env_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int logagent_plugin_env_init </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>context</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>plugin global environment init </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">context</td><td>take json in and plugin's global environment config out</td></tr>
  </table>
  </dd>
</dl>
<p>logagent will maintained a plugin list. This function is used for global init for plugin. </p>

</div>
</div>
<a id="a95dd35e4770fc0510fcc668e78aabd36"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a95dd35e4770fc0510fcc668e78aabd36">&#9670;&nbsp;</a></span>logagent_plugin_exit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int logagent_plugin_exit </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>gconfig</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>context</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>plugin exit function </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">gconfig</td><td>plugin global config structure </td></tr>
    <tr><td class="paramname">context</td><td>take plugin pconfig in </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success</dd></dl>
<p>logagent will call exit function for all plugins, the context will take plugin's own config in, and you need to do some clean work, and remember to free the config structure.</p>
<dl class="section note"><dt>Note</dt><dd>this function must be thread safety and noblocked. </dd></dl>

</div>
</div>
<a id="ae01dcc8ad838b79d7441a7b804f9f6c7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae01dcc8ad838b79d7441a7b804f9f6c7">&#9670;&nbsp;</a></span>logagent_plugin_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int logagent_plugin_init </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>gconfig</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>context</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>plugin init function </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">gconfig</td><td>plugin global config structure </td></tr>
    <tr><td class="paramname">context</td><td>take json in and plugin pconfig out </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success</dd></dl>
<p>logagent will save all plugin's config structure in it's own list node, each time when logagent call init function, context will take a json string in, when init done, you should send back the config structure's address.</p>
<dl class="section note"><dt>Note</dt><dd>this function must be thread safety and noblocked. </dd></dl>

</div>
</div>
<a id="ad169bca8e73b3ae8c0374e3971f43039"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad169bca8e73b3ae8c0374e3971f43039">&#9670;&nbsp;</a></span>logagent_plugin_work()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int logagent_plugin_work </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>gconfig</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>pconfig</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structlist__head.html">list_head</a> *&#160;</td>
          <td class="paramname"><em>log_list</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>plugin work function </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">gconfig</td><td>plugin global config structure </td></tr>
    <tr><td class="paramname">pconfig</td><td>your own plugin config structure </td></tr>
    <tr><td class="paramname">log_list</td><td>log list </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success</dd></dl>
<p>logagent will call work function one by one till exit signal received, each plugin only need to add or remove log from the log list. No need to malloc or free, log_add and log_remove just do for you.</p>
<dl class="section note"><dt>Note</dt><dd>this function must be thread safety and noblocked. </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>
